namespace AutoClub.Core.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    using AutoClub.Core.Domain;

    internal sealed class Configuration : DbMigrationsConfiguration<AutoClub.Core.Dao.AutoClubDataContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(AutoClub.Core.Dao.AutoClubDataContext context)
        {
            string system = "System";
            DateTime today = DateTime.Now;

            context.CarCategories.AddOrUpdate(new CarCategory() { Active = true, CreatedBy = system, CreatedOn = today, Value = CarCategoryEnum.NotSet, Description = "No seleccionado" },
                new CarCategory() { Active = true, CreatedBy = system, CreatedOn = today, Value = CarCategoryEnum.Category1, Description = "Categoria 1" },
                new CarCategory() { Active = true, CreatedBy = system, CreatedOn = today, Value = CarCategoryEnum.Category2, Description = "Categoria 2" },
                new CarCategory() { Active = true, CreatedBy = system, CreatedOn = today, Value = CarCategoryEnum.Category3, Description = "Categoria 3" });

            context.RaceStates.AddOrUpdate(new RaceState() { Active = true, CreatedBy = system, CreatedOn = today, Value = RaceStateEnum.NotSet, Description = "No seleccionado" },
                new RaceState() { Active = true, CreatedBy = system, CreatedOn = today, Value = RaceStateEnum.Opened, Description = "Abierta" },
                new RaceState() { Active = true, CreatedBy = system, CreatedOn = today, Value = RaceStateEnum.Suspended, Description = "Suspendida" },
                new RaceState() { Active = true, CreatedBy = system, CreatedOn = today, Value = RaceStateEnum.Closed, Description = "Cerrada" });

            context.UserRoles.AddOrUpdate(new UserRol() { Active = true, CreatedBy = system, CreatedOn = today, Value = UserRolEnum.NotSet, Description = "No seleccionado" },
                new UserRol() { Active = true, CreatedBy = system, CreatedOn = today, Value = UserRolEnum.Administrator, Description = "Administrador" },
                new UserRol() { Active = true, CreatedBy = system, CreatedOn = today, Value = UserRolEnum.Pilot, Description = "Piloto de Carrera" });
        }
    }
}
